<!-- templates/user.html -->
{% extends "base.html" %}

{% block title %}{{ user.username }}的主页 - 校园摄影投票系统{% endblock %}

{% block content %}
    <div class="row">
        <div class="col-md-4">
            <div class="card mb-4">
                <div class="card-body text-center">
                    <!-- 正确显示用户头像 -->
                    {% if user.avatar %}
                        <img src="{{ url_for('static', filename='uploads/' + user.avatar) }}" 
                             class="rounded-circle mb-3" width="150" alt="头像">
                    {% else %}
                        <img src="{{ url_for('static', filename='images/default-avatar.png') }}" 
                             class="rounded-circle mb-3" width="150" alt="头像">
                    {% endif %}
                    
                    <h2>{{ user.username }}</h2>
                    <p class="text-muted">{{ user.bio or '暂无简介' }}</p>
                    
                    {% if current_user == user %}
                    <a href="{{ url_for('main.edit_profile') }}" class="btn btn-outline-primary">
                        编辑资料
                    </a>
                    {% endif %}
                </div>
            </div>
        </div>
        
        <!-- 其他内容保持不变 -->
        <div class="col-md-8">
            <h3 class="mb-4">{{ user.username }}的作品</h3>
            
            {% if photos %}
            <div class="row">
                {% for photo in photos %}
                <div class="col-md-6 mb-4">
                    <div class="card h-100">
                        <a href="{{ url_for('main.photo_detail', photo_id=photo.id) }}">
                            <img src="{{ url_for('static', filename='uploads/' + photo.thumbnail) }}" 
                                 class="card-img-top" alt="{{ photo.title }}">
                        </a>
                        <div class="card-body">
                            <h5 class="card-title">{{ photo.title }}</h5>
                            <p class="card-text">
                                <small class="text-muted">{{ photo.vote_count }} 票</small>
                            </p>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
            {% else %}
            <div class="alert alert-info">
                {% if current_user == user %}
                您还没有上传过作品，<a href="{{ url_for('main.upload') }}">立即上传</a>
                {% else %}
                该用户还没有上传过作品
                {% endif %}
            </div>
            {% endif %}
        </div>
    </div>
{% endblock %}